<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Page extends Controller_Common {

	public $template='layout/index';

	public function emptyPost() {
		return array(
			'name' => '',
			'email' => '',
			'phone' => '',
			'content' => ''
		);
	}

	public function action_one() {
		$page = ORM::factory('Pages')->getOne($this->postfix, $this->request->param('id'));

		if (!empty($page)) {
			$this->buildCarcas();

			if ($this->request->param('id') == 'company' || $this->request->param('id') == 'about') {
				$this->template->title = 'Zuber - '.$page->title;
				$this->template->content = View::factory('pages/companyPage', array(
					'page' => $page,
					'team' => DB::select('id', array('fio'.$this->postfix, 'fio'), array('post'.$this->postfix, 'post'), 'image')->from('team')->order_by('sort', 'DESC')->as_object()->execute(),
				));
			} else {
				$this->template->title = 'Zuber - '.$page->title;
				$this->template->content = View::factory('pages/page', array(
					'page' => $page
				));
			}
		} else {
			throw HTTP_Exception::factory(404, ':text', array(
				':text' => $this->sitetext['not_found']['_value']
			));
		}

	}
}